<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>多选，可选择父节点，可重复选</title>
		<link href="../select3.css" rel="stylesheet" />
	</head>

	<body>
		<!--表单包裹层-->
		<div style="width: 360px; margin: 10px;">
			<div class="select3-ui" id="xxx" data-dataSource=""></div>
		</div>
		<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
		<script type="text/javascript" src="../select3.js" ></script>
		<script>
		var data2 = {
					"pageSize": 10,
					"pageNo": 1,
					"total": 11,
					"pageNum":2,
					"nodes": [
						{
							"text": "渝中区",
							"value": "001",
							"selected": false
						}, 
						{
							"text": "南岸区",
							"value": "002",
							"selected": false
						}, 
						{
							"text": "巴南区",
							"value": "003",
							"selected": false
						}, 
						{
							"text": "九龙坡区",
							"value": "004",
							"selected": false
						}, 
						{
							"text": "高新区",
							"value": "005",
							"selected": false
						}, 
						{
							"text": "璧山区",
							"value": "006",
							"selected": false
						}, 
						{
							"text": "渝北区",
							"value": "007",
							"selected": false
						}, 
						{
							"text": "两江新区",
							"value": "008",
							"selected": false
						}, 
						{
							"text": "江北区",
							"value": "009",
							"selected": false
						}, 
						{
							"text": "江津区",
							"value": "010",
							"selected": false
						}]
			};
			
			
			var data3 = {
					"pageSize": 10,
					"pageNo": 2,
					"total": 11,
					"pageNum":2,
					"nodes": [
					{
							"text": "永川区",
							"value": "011",
							"selected": false
						}
					]
			};
			
			var data4 = {
					"pageSize": 10,
					"pageNo": 0,
					"total": 0,
					"pageNum":0,
					"nodes": [
					]
			};
			
			var select1 = $("#xxx").select3(
			{
				mode: 'remote',
				placeholder: '请选择城市',
				multiple:true,//是否可以多选
				selectParent:true,//是否可以选择父节点
				duplicate:true,//是否可以重复选
				enterSearch: true//
			},
			'xxx',
			function(select, keyword, pageSize, pageNo){
				if(keyword == '直辖市'){
					return data1;
				}else if(keyword == '重庆'){
					if(pageNo == 1){
						return data2;
					}else{
						return data3;
					}
				}else{
					return data4;
				}
			});
		</script>
	</body>
</html>
				